<?php
class mmg_saran extends CI_Model{
	var $mgt_saran = "mgt_saran";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_saran,$nama_saran,$email_saran,$subjek_saran,$pesan_saran)
	{
		$this->id_saran= $id_saran;
		$this->nama_saran= $nama_saran;
		$this->email_saran= $email_saran;
		$this->subjek_saran= $subjek_saran;
		$this->pesan_saran= $pesan_saran;
	}
	
	function getList(){
		$query = $this->db->get($this->mgt_saran);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}	
	
	function create()
	{		
		$arrayData = array(
			'id_saran'=>$this->id_saran,
			'nama_saran'=>$this->nama_saran,
			'email_saran'=>$this->email_saran,
			'subjek_saran'=>$this->subjek_saran,
			'pesan_saran'=>$this->pesan_saran
		);
		return $this->db->insert($this->mgt_saran, $arrayData);
	}
	
	function update($id_saran)
	{
		$arrayData = array(
			'nama_saran'=>$this->nama_saran,
			'email_saran'=>$this->email_saran,
			'subjek_saran'=>$this->subjek_saran,
			'pesan_saran'=>$this->pesan_saran
		);
		$this->db->where('id_saran', $id_saran);
		return $this->db->update($this->mgt_saran, $arrayData);
	}
        
	function remove($id_saran)
	{
		$this->db->where('id_saran', $id_saran);
		return $this->db->delete($this->mgt_saran);
	}	
	
	function detail($id_saran)
	{
		$this->db->where('id_saran', $id_saran);
		$query = $this->db->get($this->mgt_saran);	
		return $query->result_array();
	}
}
?>